//
//  AlterInfoController.m
//  Korea
//
//  Created by 崔剑 on 15/9/6.
//  Copyright (c) 2015年 KoreaGo. All rights reserved.
//

#import "AlterInfoController.h"
#import "Header.h"

@interface AlterInfoController ()

@property (nonatomic, strong) UITextField *alterTextField;


@end

@implementation AlterInfoController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = self.titleName;
    self.view.backgroundColor = [UIColor colorWithRGB:0xf3f4f8 alpha:1];
    self.navigationController.navigationBar.translucent = NO;
    
    self.alterTextField = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, self.view.frame.size.width - 20, 40)];
    self.alterTextField.placeholder = self.titleName;
    self.alterTextField.borderStyle = UITextBorderStyleRoundedRect;
    self.alterTextField.clearButtonMode = UITextFieldViewModeAlways;
    self.alterTextField.keyboardType = UIKeyboardTypeDefault;
    self.alterTextField.keyboardAppearance = UIKeyboardAppearanceLight;
    self.alterTextField.returnKeyType = UIReturnKeySend;
    [self.view addSubview:self.alterTextField];
    
    UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHide:)];
    //设置成NO表示当前控件响应后会传播到其他控件上，默认为YES。
    tapGestureRecognizer.cancelsTouchesInView = NO;
    //将触摸事件添加到当前view
    [self.view addGestureRecognizer:tapGestureRecognizer];
    
    // 返回键
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back@2x.png"] style:UIBarButtonItemStylePlain target:self action:@selector(leftAction:)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];

    // 保存键
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"preserve@2x.png"] style:UIBarButtonItemStylePlain target:self action:@selector(rightAction:)];
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
    
}


- (void)rightAction:(UIBarButtonItem *)button
{
    // 保存
    
    
}

- (void)leftAction:(UIBarButtonItem *)button
{
    // 返回
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)keyboardHide:(UITapGestureRecognizer*)tap{
    [self.alterTextField resignFirstResponder];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
